package Demo16_30.Test17;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by 14229 on 2020/1/21.
 */
public class Test {
    public static void main(String[] args) {

        Student s1=new Student("zhangsan",18,"男");
        Student s2=new Student("lihong",22,"女");
        Student s3=new Student("wangwu",19,"男");
        Student s4=new Student("wuwu",8,"女");
        Student s5=new Student("lilin",35,"男");

        List<Student> list=new ArrayList<Student>();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        list.add(s5);

        int countnan = 0;
        int countnv = 0;
        int countMAX = 0;
        int countMIN = 0;
        Map<String,Integer> map = new HashMap<>();
        for (Student stu : list) {
            if (stu.getSex().equals("男")){
                countnan++;
            }else {
                countnv++;
            }
            if (stu.getAge()>=18){
                countMAX++;
                map.put("成年",countMAX);
            }else {
                countMIN++;
                map.put("未成年",countMIN);
            }

        }
        System.out.println(map);
        System.out.println("男（"+countnan+"）   "+"女（"+countnv+"）");


    }
}
